package com.goktech.test;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName time
 * @Description TODO
 * @Author 邱华英
 * @Date 2022/10/9 19:50
 * @Version 1.0
 */

public class time {
    public static void main(String[] args) {
//        String dataStr = "2022-10-11";
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        Date startTime = null;
//        try {
//            startTime = simpleDateFormat.parse(dataStr);
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        Date endTime = new Date();  //获取当前时间
//        long s = endTime.getTime()-startTime.getTime();  //endeTime和startTime是两个要计算的时间
//        TimeUnit time = TimeUnit.DAYS;
//        long days = time.convert(s, TimeUnit.MILLISECONDS);
//        System.out.println(days);

        try {
            String inputStr = "123";
            String inputStr1 = "123";
            String result = getResult(inputStr);
            String result1 = getResult(inputStr1);
            System.out.println(result.equals(result1));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private static final String KEY_MD5 = "MD5";

    private static  String  getResult(String inputStr)
    {
        BigInteger bigInteger=null;

        try {
            MessageDigest md = MessageDigest.getInstance(KEY_MD5);
            byte[] inputData = inputStr.getBytes();
            md.update(inputData);
            bigInteger = new BigInteger(md.digest());
        } catch (Exception e) {e.printStackTrace();}
        return bigInteger.toString(16);
    }
}
